package com.zb.jnlxc.dao;

import com.ZLHW.base.dao.DAO;
import com.zb.jnlxc.model.Depart;
import com.zb.jnlxc.model.LiaoKuang;
import com.zb.jnlxc.model.Truck;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by Administrator on 2015/9/20.
 */
@Component
public class TruckDAO extends DAO<Truck,Integer> {

    public Truck getBycode(String code) {
        List<Truck> list = getByColumn("code", code);
        if (CollectionUtils.isNotEmpty(list)) {
            return list.get(0);
        } else {
            return null;
        }
    }

    public List<Truck> searchByCode(String code){
        StringBuffer hql = new StringBuffer("select t from Truck t where t.code like ?");
        return findByHQLWithIndex( hql.toString(),0,10,code+"%");
    }



}
